package feizhou.untils.tools.signature;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName: SignatureParam
 * @Description 签名工具类
 * @Author feizhou
 * @Date 2023/11/13  14:26
 * @Verson 1.0
 **/
public class SignatureUtil {


    /**
     * 生成签名值
     *
     * @param
     * @return java.lang.String
     * @author <a href="920786312@qq.com">周飞</a>
     * @since 2023/11/13 14:30
     */
    public static String generateSignature(List<SignatureParam> signatureParams, Signature signature) {
        return signature.generate(signatureParams);
    }

    public static void main(String[] args) {
        List<SignatureParam> signatureParams = new ArrayList<>();
        signatureParams.add(new SignatureParam("x-qys-open-timestamp", "2", 3));
        signatureParams.add(new SignatureParam("x-qys-open-nonce", "2", 4));
        signatureParams.add(new SignatureParam("x-qys-open-accesstoken", "1", 1));
        signatureParams.add(new SignatureParam("AppSecret", "2", 2));

        Collections.sort(signatureParams);
        String s = generateSignature(signatureParams, new MD5Signature());
        System.out.println(s);

    }

}